<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>登录页面</title>
  <!-- 引入Bootstrap样式 -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <!-- 自定义CSS样式 -->
  <style>
    body {
      background-color: #f7f7f7;
      height: 100vh;
    }
    .login-container {
      max-width: 400px;
      margin: 100px auto;
      background-color: #fff;
      padding: 30px;
      border-radius: 8px;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
    .login-title {
      text-align: center;
      margin-bottom: 30px;
    }
    .form-control {
      margin-bottom: 20px;
    }
    .btn-primary {
      width: 100%;
    }
    .alert {
      display: none;
    }
  </style>
</head>
<body>

  <div class="container">
    <div class="login-container">
      <h2 class="login-title">登录</h2>
      <!-- 错误提示信息 -->
      <div id="error-message" class="alert alert-danger" role="alert">
        用户名或密码错误，请重试。
      </div>
      <form id="login-form">
        <!-- 用户名输入框 -->
        <div class="mb-3">
          <label for="username" class="form-label">用户名</label>
          <input type="text" class="form-control" id="username" placeholder="请输入用户名" required>
        </div>

        <!-- 密码输入框 -->
        <div class="mb-3">
          <label for="password" class="form-label">密码</label>
          <input type="password" class="form-control" id="password" placeholder="请输入密码" required>
        </div>

        <!-- 提交按钮 -->
        <button type="submit" class="btn btn-primary">登录</button>

        <!-- 忘记密码链接 -->
        <div class="mt-3 text-center">
          <a href="#">忘记密码?</a>
        </div>
      </form>
    </div>
  </div>

  <!-- 引入Bootstrap JS -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>

  <!-- jQuery代码 -->
  <script>
    $(document).ready(function() {
      // 登录表单提交事件
      $("#login-form").submit(function(event) {
        event.preventDefault();  // 防止默认的表单提交行为

        // 获取输入的用户名和密码
        var username = $("#username").val();
        var password = $("#password").val();

        // 模拟的用户名和密码
        var correctUsername = "admin";
        var correctPassword = "123456";

        // 检查用户名和密码
        if (username === correctUsername && password === correctPassword) {
          // 登录成功，跳转到index.html
          window.location.href = "index.html";
        } else {
          // 显示错误提示
          $("#error-message").fadeIn();
        }
      });
    });
  </script>
</body>
</html>
